#include "common.h"

PUBLIC S4B   UHexStringToNumber(PCCHAR string,U4B number,PU4B out)
{
   U4B result=0;
   S2B i=0;
   S1B j=0;
   for(;i<number;i++)
   {
      j=OneHexCharToNumber(string[i]);
      if(j==16)
      {break;}
      result=result*16+j;
      *out=result;
   }
   return (i);
}
PUBLIC S4B   UDecStringToNumber(PCCHAR string,U4B number,PU4B out)
{ 
   U4B result=0;
   S2B i=0;
   S1B j=0;
   for(;i<number;i++)
   {
      j=OneDecCharToNumber(string[i]);
      if(j==10)
      {break;}
      result=result*10+j;
      *out=result;
   }
   return (i);
}
PUBLIC S4B   U4BToBigHexString(U4B integer,PCHAR buffer)
{ 
   
   S1B  i=0,j=0;
   U1B  bufferposition=0;
   if(integer==0)
   { buffer[0]='0'; return 1;}
   for(i=7;i>=0;i--)
   {
     j=GetLastHalfByte(integer>>(i*4));
     if(bufferposition==0 && j==0)
      continue;
      if(j<10)
        j+=48;
      else
        j+=55;
      buffer[bufferposition]=j;
      bufferposition++;
   }
   return bufferposition;  
}
